
package com.wyzz.hr.action;

import java.util.List;
import java.util.Map;
import org.apache.axis.utils.StringUtils;

import com.wyzz.hr.base.BaseAction;
import com.wyzz.hr.base.ComonBeans;
import com.wyzz.hr.base.DWRUtil;
import com.wyzz.hr.bo.IRecruitapplierBo;
import com.wyzz.hr.bo.IRecruitchannelBo;
import com.wyzz.hr.bo.IRecruitplanBo;
import com.wyzz.hr.pojo.Recruitapplier;
import com.wyzz.hr.pojo.Recruitplan;

public class RecruitapplierCreateInit extends BaseAction {

	public RecruitapplierCreateInit() {
	}

	public String execute() throws Exception {
		IRecruitchannelBo recruitchannelBO = (IRecruitchannelBo) getBean("channelBo");
		IRecruitplanBo recruitplanBO = (IRecruitplanBo) getBean("recruitplanBO");
		IRecruitapplierBo applierBo = (IRecruitapplierBo) getBean("applierBo");
		String auth = authorityCondition;
		if ("HR".equals(auth) || "HRM".equals(auth))
			canModify = Integer.valueOf(1);
		else
			canModify = Integer.valueOf(0);
		if (!StringUtils.isEmpty(applierId))
			applier = applierBo.loadApplierById(applierId);
		else
			applier = new Recruitapplier();
		RecruitplanList = recruitplanBO.searchApprovePlanWithCondition(null);
		RecruitchannelList = recruitchannelBO.getObjects(
				com.wyzz.hr.pojo.Recruitchannel.class, null);
		String statusArr[] = { String.valueOf(2), String.valueOf(17),
				String.valueOf(11), String.valueOf(16), String.valueOf(18),
				String.valueOf(19), String.valueOf(21), String.valueOf(22) };
		applierStatus = ComonBeans.getValuesToMap(
				Recruitapplier.PROP_RECA_STATUS, statusArr,
				new boolean[] { true });
		return "success";
	}

	public Recruitapplier loadRecruitapplierInfo(String appId) {
		if (StringUtils.isEmpty(appId))
			return null;
		IRecruitapplierBo applierBo = (IRecruitapplierBo) getBean("applierBo");
		if (!DWRUtil.checkAuth("filterResume", "execute").equals("HR"))
			return null;
		String fetch[] = {
				Recruitapplier.PROP_RECA_PLAN_ID,
				(new StringBuilder()).append(Recruitapplier.PROP_RECA_PLAN_ID)
						.append(".").append(Recruitplan.PROP_RECP_PB_NO)
						.toString(), Recruitapplier.PROP_RECA_CHANNEL_NO,
				Recruitapplier.PROP_RECA_INTERVIEWER,
				Recruitapplier.PROP_RECA_REFER_EMP_NO };
		Recruitapplier applier = applierBo.loadApplier(appId, fetch);
		applier.setChannelStr(applier.getRecaChannelNo().getRecchName());
		if (applier.getRecaPlanId() != null)
			applier.setPlanStr(applier.getRecaPlanId().getRecpNo().toString());
		if (applier.getRecaInterviewer() != null)
			applier
					.setInterviewerStr(applier.getRecaInterviewer()
							.getEmpName());
		if (applier.getRecaReferEmpNo() != null)
			applier.setReferEmpStr(applier.getRecaReferEmpNo().getEmpName());
		return applier;
	}

	public List chooseRecruitplanList(String condition) {
		IRecruitplanBo recruitplanBO = (IRecruitplanBo) getBean("recruitplanBO");
		return recruitplanBO.searchApprovePlanWithCondition(condition);
	}

	public List getRecruitchannelList() {
		return RecruitchannelList;
	}

	public void setRecruitchannelList(List recruitchannelList) {
		RecruitchannelList = recruitchannelList;
	}

	public List getRecruitplanList() {
		return RecruitplanList;
	}

	public void setRecruitplanList(List recruitplanList) {
		RecruitplanList = recruitplanList;
	}

	public Map getApplierStatus() {
		return applierStatus;
	}

	public void setApplierStatus(Map applierStatus) {
		this.applierStatus = applierStatus;
	}

	public Recruitapplier getApplier() {
		return applier;
	}

	public void setApplier(Recruitapplier applier) {
		this.applier = applier;
	}

	public int getShow() {
		return show;
	}

	public void setShow(int show) {
		this.show = show;
	}

	public Recruitplan getPlan() {
		return plan;
	}

	public void setPlan(Recruitplan plan) {
		this.plan = plan;
	}

	public String getApplierId() {
		return applierId;
	}

	public void setApplierId(String applierId) {
		this.applierId = applierId;
	}

	public String getSrcAction() {
		return srcAction;
	}

	public void setSrcAction(String srcAction) {
		this.srcAction = srcAction;
	}

	public Integer getCanModify() {
		return canModify;
	}

	public void setCanModify(Integer canModify) {
		this.canModify = canModify;
	}

	private List RecruitchannelList;
	private List RecruitplanList;
	private Map applierStatus;
	private Recruitapplier applier;
	private Recruitplan plan;
	private int show;
	private String applierId;
	private String srcAction;
	private Integer canModify;
}
